<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }">
    <div
      :style="{
        'background-image':
          (index + 1) % 2 === 0
            ? `url(${publicUrls + 'free/style1/displayBoardStyle3RightBg.webp'})`
            : `url(${publicUrls + 'free/style1/displayBoardStyle3LeftBg.webp'})`,
      }"
      @contextmenu.stop="emit('onContextMenuChild', $event, index)"
      class="exhibits-item border-hover-style"
      :class="{ 'exhibits-item-mg': (index + 1) % 2 === 0 }"
      v-for="(item, index) in props.info.showpieceList"
      :key="index"
    > 
      <div class="cover-box">
        <img class="cover" v-lazy="getLinkUrl(item.coverUrl,'?imageView2/3/w/600/format/webp')" alt="" />
        <img class="flower-btn" v-lazy="publicUrls + 'free/style1/flower.png?imageView2/3/format/webp'" />
        <div class="mask-layer" @click="viewImg(item.moduleId, item.id)">
          <p>{{ item.name }}</p>
        </div>
      </div>
    </div>
  </div>
</template>         
     
<script lang="ts">
export default defineComponent({
  name: 'style3',
});
</script>

<script setup lang="ts">
import { urls, getLinkUrl } from '@/utils/request/upload';
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick, defineComponent } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const ImgVisible = ref(false);
const ImgUrl = ref('');

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};
const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};
// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>
 
<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  z-index: 999;
  padding: 0px !important;
  -webkit-box-reflect: below 40% linear-gradient(transparent, rgba(0, 0, 0, 0.2));
}  
   
.active {  
  :deep(.flot-menu) {
    display: flex;
  }    
}  
:deep(.active) {
  z-index: 999;
}
:deep(.vdr-handle) {
  z-index: 66;
} 
.exhibits-item {
  display: flex;
  justify-content: center;
  height: 630px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding-right: 28px;
  padding-left: 20px;
  margin-left: -11px;
  -webkit-box-reflect: below -2% linear-gradient(transparent, rgba(0, 0, 0, 0.25));

  &:hover {
    .mask-layer {
      opacity: 1;
    }
    .flower-btn {
      display: none;
    }
  }
  .cover-box {
    width: 162px;
    height: 365px;
    position: relative;
    background: url(https://static.jiyi.show/free/style1/woodgrain.png) no-repeat center/100% 100%;
    margin-top: 3px;
    .cover {
      width: 100%;
      height: 100%;
      object-fit: contain;
      box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.15);
      margin-left: 1px;
    }
    .flower-btn {
      width: 40px;
      height: 40px;
      object-fit: cover;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      animation: flower 2s linear infinite;
      @keyframes flower {
        0% {
          opacity: 0;
        }
        40% {
          opacity: 100%;
        }
        80% {
          opacity: 100%;
        }
        100% {
          opacity: 0;
        }
      }
    }
  }
  &:first-child {
    margin-left: 0;
  }
  &:nth-child(odd) {
    z-index: 1;
    padding-top: 98px;
  }
  &:nth-child(even) {
    z-index: 0;
  }
  .mask-layer {
    width: 101%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(85, 59, 42, 0.4);
    padding: 0 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
    opacity: 0;
    z-index: 2;
    ::v-deep p {
      color: #fef3df;
      text-align: center;
      font-family: 'SourceHanSerifCN-Bold';
      font-size: 18px;
      line-height: 24px;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
  }
}
.exhibits-item-mg {
  .cover-box {
    margin-top: 162px;
    .cover {
      height: 100%;
      object-fit: scale-down;
    }
  }
}
</style>